import requests, re, xlwt
headers = {
    'cookie': '__jdu=1547878795; shshshfpa=ed05a0fb-c052-fba9-5cf7-4f83c88f0ef8-1585113861; shshshfpb=kM3M1iZZkeEwacSn8El7Bjg%3D%3D; cn=0; areaId=18; ipLoc-djd=18-1501-1503-0; PCSYCityID=CN_430000_430400_430421; unpl=V2_ZzNtbUNfFkdzXE4Gck4JBGIDF18SBBAUcghGVitLCQFmBxcKclRCFnQUR1BnGVgUZgoZWEVcQRVFCEdkeBBVAWMDE1VGZxBFLV0CFSNGF1wjU00zQwBBQHcJFF0uSgwDYgcaDhFTQEJ2XBVQL0oMDDdRFAhyZ0AVRQhHZHsdWQNuBRtbSlNzJXI4dmR8HV4BYQQiXHJWc1chVEVScx9bAyoDFlhEXkUccwBCZHopXw%3d%3d; __jdv=76161171|baidu-pinzhuan|t_288551095_baidupinzhuan|cpc|0f3d30c8dba7459bb52f2eb5eba8ac7d_0_09dc7e9c8fd04143abb06113acd5054f|1589503620222; __jda=122270672.1547878795.1585113860.1589462050.1589503620.7; __jdc=122270672; shshshfp=efd6981a092ba3d643ba2e8c9bc86d89; shshshsID=3674f2d15fb9f3152619de59608fa4f0_2_1589503628748; 3AB9D23F7A4B3C9B=FCEQWI22ZXMLR5ZOBN275LMTSGRG4PGKZOMSXQNLRPC2URTVCY3X33FKGPM7WZBC5H7DYPK35P6ZAFT4KQAR6YYTLE; __jdb=122270672.4.1547878795|7.1589503620',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'
}

url = 'https://search-x.jd.com/Search?callback=jQuery6416107&area=18&enc=utf-8&keyword=%E6%89%8B%E6%9C%BA&adType=7&page=1&ad_ids=291%3A19&xtest=new_search&_=1589503642013'


res = requests.get(url, headers=headers).text

price = re.findall('"pc_price":"(.*?)"', res)
spu_id = re.findall('"spu_id":"(.*?)"', res)
for i in spu_id:
    url_goods = 'https://item.jd.com/{}.html'.format(spu_id)
    res = requests.get(url, headers=headers).text
    title = re.findall('"ad_title":"(.*?)"', res)
    shop_name = re.findall('"shop_name":"(.*?)"', res)
    color = re.findall('"color":"(.*?)"', res)
for i in zip(title,shop_name):
    print(i)
print(len(title))